<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> <head>
<TITLE>CIL Disassembler (Ildasm.exe)</TITLE>
<link rel="stylesheet" type="text/css" href="../rotor.css">
</head>
<body>

<H1>Common Intermediate Language Disassembler (ildasm.exe)</H1>

<P>The Common Intermediate Language (CIL) Disassembler is a companion tool to 
the CIL Assembler. The CIL Disassembler takes a portable executable (PE) file that 
contains CIL code and creates a text file suitable as input to Ilasm.</P>

<P>The Shared Source CLI (SSCLI) version of The CIL Disassembler does not have a GUI and outputs only to 
the console or a file.</P>

<P>The application file for the CIL disassembler is named ildasm.exe 
in the Shared Source CLI (SSCLI)  on Microsoft&reg; Windows&reg;.&nbsp; </P>
    <p>
        Because the  SSCLI  implementation of CIL Disassembler is 
console-only, the following features in the .NET Framework Microsoft&nbsp;Intermediate Language Disassembler implementation 
are not supported in the SSCLI:</p>

<ul>
  <li><b>/nobar</b>&nbsp;&nbsp; 

<ul>
  <li>Suppresses disassembly progress bar window pop-up.</li>
</ul>

  </li>
  <li><b>/text</b>&nbsp;&nbsp;&nbsp;&nbsp; 

<ul>
  <li>Outputs to console.&nbsp; Not useful because it is the only supported mode 
  in the SSCLI implementation.</li>
</ul>

  </li>
</ul>

<h4>Usage</h4>

<blockquote>

<PRE class="syntax"><B>ildasm </B>[options] [<I>PEfilename</I>] [<I>options</I>]</PRE>

</blockquote>

<P>The following options are available for working with .exe and .dll files that 
contain CIL.</P>

<P>Options can be specified using either a dash (-) or a slash (/). </P>
<table border=1  width="100%">

<TR VALIGN="top">
<TH width=30%>Option</TH>
<TH width=70% colspan="2">Description</TH>
</TR>

<tr>
<TD width=30%><B>/all</B></TD>
<TD width=70% colspan="2">Specifies a combination of the <B>/header</B>, <B>/bytes</B>, and <B>/tokens</B> options.</TD>
</tr>

<TR VALIGN="top">
<TD width=30%><B>/bytes</B></TD>
<TD width=70% colspan="2">Shows actual bytes, in hexadecimal format, as instruction comments.</TD>
</TR>

<tr>
<TD width=30%><b>/classlist</b></TD>
<TD width=70% colspan="2">Includes a list of classes defined in the module.</TD>
</tr>

<tr>
<TD width=30%><B>/header</B></TD>
<TD width=70% colspan="2">Includes file header information in the output.</TD>
</tr>
<tr>
<TD width=30%><B>/item:</B><I>class</I>[<b>.</b><I>method </I>[(<I>sig)</I>]]</TD>
<TD width=70% colspan="2">Disassembles the following depending  on the argument supplied:
<UL>
	<LI>Disassembles the specified <I>class.</I></li>

	<LI>Disassembles the specified <I>method</I> of the <I>class.</I></li>

	<LI>Disassembles the <I>method</I> of the <I>class</I> with the specified signature <I>sig. </I>Specify the signature with a return type and as many parameters as required. For example, <I>returntype </I>(<I>param1</I>, <I>param2</I>,..<I>paramn</I>).</li>
</UL>
</TD>
</tr>

<TR VALIGN="top">
<TD width=30%><B>/linenum</B></TD>
<TD width=70% colspan="2">Includes references to original source lines.</TD>
</TR>

<TR VALIGN="top">
<TD width=30% rowspan="9"><b>/metadata[=<i>specifier</i>]</b> </TD>
<TD width=70% colspan="2">Shows metadata.&nbsp; This is commonly used with the <b>
/noil </b>option to  view a text dump of the assembly metadata.<p><i>
Specifier</i> can be:</TD>
</TR>

<TR VALIGN="top">
<TD width="15%">mdheader</TD>
<TD width="35%">Shows metadata header information and sizes.</TD>
</TR>

<TR VALIGN="top">
<TD width="15%">hex</TD>
<TD width="35%">Shows more things in hexadecimal as well as words.</TD>
</TR>

<TR VALIGN="top">
<TD width="15%">csv</TD>
<TD width="35%">Shows the header sizes in Comma Separated format.</TD>
</TR>

<TR VALIGN="top">
<TD width="15%">unrex</TD>
<TD width="35%">Shows unresolved externals.</TD>
</TR>

<TR VALIGN="top">
<TD width="15%">schema</TD>
<TD width="35%">Shows the metadata schema information.</TD>
</TR>

<TR VALIGN="top">
<TD width="15%">raw</TD>
<TD width="35%">Shows the raw metadata tables.</TD>
</TR>

<TR VALIGN="top">
<TD width="15%">heaps </TD>
<TD width="35%">Shows the raw heaps.</TD>
</TR>

<TR VALIGN="top">
<TD width="15%">validate</TD>
<TD width="35%">Validate the consistency of the metadata.</TD>
</TR>

<tr>
<TD width=30%><B>/noil</B></TD>
<TD width=70% colspan="2">Suppresses CIL assembly code output.</TD>
</tr>
<tr>
<TD width=28%><B>/output:</B><I>filename</I></TD>
<TD width=72% colspan="2">Creates an output file with the specified <I>filename</I></TD>
</tr>

<TR VALIGN="top">
<TD width=30%><b>/pretty</b></TD>
<TD width=70% colspan="2">Pretty-prints CIL as pseudo-C code in comments</TD>
</TR>

<TR VALIGN="top">
<TD width=30%><B>/pubonly</B></TD>
<TD width=70% colspan="2">Disassembles only public types and members. Equivalent to <B>/visibility:PUB</B>.</TD>
</TR>

<TR VALIGN="top">
<TD width=30%><B>/quoteallnames</B></TD>
<TD width=70% colspan="2">Includes all names in single quotes.</TD>
</TR>

<TR VALIGN="top">
<TD width=30%><B>/raweh</B></TD>
<TD width=70% colspan="2">Shows exception handling clauses in raw form.</TD>
</TR>

<TR VALIGN="top">
<TD width=30%><b>/stats</b></TD>
<TD width=70% colspan="2">Includes statistics on the image.</TD>
</TR>

<TR VALIGN="top">
<TD width=30%><B>/source</B></TD>
<TD width=70% colspan="2">Shows original source lines as comments.</TD>
</TR>

<TR VALIGN="top">
<TD width=30%><B>/tokens</B></TD>
<TD width=70% colspan="2">Shows metadata tokens of classes and members.</TD>
</TR>

<tr>
<TD width=30%><B>/unicode</B></TD>
<TD width=70% colspan="2">Uses Unicode encoding for the output.</TD>
</tr>
<tr>
<TD width=30%><B>/utf8</B></TD>
<TD width=70% colspan="2">Uses UTF-8 encoding for the output.  ANSI is the default.</TD>
</tr>

<TR VALIGN="top">
<TD width=30% rowspan="8"><B>/visibility:</B><I>vis </I>[+<I>vis</I> ...]</TD>
<TD width=70% colspan="2">Disassembles only types or members with the specified visibility.  
<p>The following are valid values for <I>vis</I>.
</TD>
</TR>

<TR VALIGN="top">
<TD width="35%"><B>PUB</B></TD>
<TD width="35%">Public</TD>
</TR>

<TR VALIGN="top">
<TD width="35%"><B>PRI</B></TD>
<TD width="35%">Private</TD>
</TR>

<TR VALIGN="top">
<TD width="35%"><B>FAM</B></TD>
<TD width="35%">Family</TD>
</TR>

<TR VALIGN="top">
<TD width="35%"><B>ASM</B></TD>
<TD width="35%">Assembly</TD>
</TR>

<TR VALIGN="top">
<TD width="35%"><B>FAA</B></TD>
<TD width="35%">Family and Assembly</TD>
</TR>

<TR VALIGN="top">
<TD width="35%"><B>FOA</B></TD>
<TD width="35%">Family or Assembly</TD>
</TR>

<TR VALIGN="top">
<TD width="35%"><B>PSC</B></TD>
<TD width="35%">Private Scope</TD>
</TR>
<tr>
<TD width=28%><B>/?</B></TD>
<TD width=72% colspan="2">Displays the command syntax and options for the tool.</TD>
</tr>

</table>

<P class=indent><B>Note</B>&nbsp;&nbsp;&nbsp;All options for the CIL 
Disassembler are case-insensitive and recognized by the first three letters.  For example, <B>/quo</B> is equivalent to <B>/quoteallnames</B>. Options that specify arguments accept either a colon (:) or an equal sign (=) as the separator between the option and the argument. For example, <B>/output:</B><I>filename</I> is equivalent to <B>/output=</B><I>filename</I>.</P>

<H4>Remarks</H4>

<P>The text file produced by the CIL Disassembler can be used as input to the CIL Assembler. This is useful, for example, when compiling code in a programming language that does not support all the runtime metadata attributes. After compiling the code and running its output through Ildasm.exe, the resulting 
CIL text file can be hand-edited to add the missing attributes. You can then run this text file through the 
CIL Assembler to produce a final executable file.</P>

<P class=indent>Note: Currently, you cannot use this technique with PE files that contain embedded native code (for example, PE files produced by 
Microsoft&reg; Visual C++&reg; .NET).</P>

<P>If you provide Ildasm.exe with a <I>PEfilename</I> argument that contains embedded resources, the tool produces multiple output files:  a text file that contains 
CIL code and, for each embedded managed resource, a .resources file produced using the resource's name from metadata.  </P>

<P>In the SSCLI implementation, if an unmanaged resource is embedded in <I>PEfilename</I>, a .res file is produced using the filename specified for 
CIL output by the <B>/output</B> option.</P>

<P class=indent>Note:&nbsp;The CIL Disassembler shows only metadata descriptions for .obj and .lib input files. 
CIL code for these file types is not disassembled.</P>

<P>You can run Ildasm.exe over an.exe or .dll file to determine whether the file is managed. If the file is not managed, the tool displays a message stating that the file has no valid common language runtime header and cannot be disassembled. If the file is managed, the tool runs successfully.</P>

<H4>Examples</H4>

<P>The following command causes the metadata and disassembled code for the PE file <CODE>MyHello.exe</CODE> 
to display in he CIL Disassembler default GUI.</P>

<PRE>ildasm myHello.exe</PRE>

<P>The following command disassembles the file <CODE>MyFile.exe</CODE> and stores the resulting 
CIL Assembler text in the file <CODE>MyFile.il</CODE>.</P>

<PRE>ildasm MyFile.exe /output:MyFile.il</PRE>

<P>The following command disassembles the file <CODE>MyFile.exe</CODE> and displays the resulting 
CIL Assembler text to the console window.</P>

<PRE>ildasm MyFile.exe /text</PRE>

<P>If the file <CODE>MyApp.exe</CODE> contains embedded managed and unmanaged resources, the following command produces four files: <CODE>MyApp.il</CODE>, <CODE>MyApp.res</CODE>, <CODE>Icons.resources, </CODE>and <CODE>Message.resources</CODE>.</P>

<PRE>ildasm MyApp.exe /output:MyApp.il</PRE>

<P>The following command disassembles the method <CODE>MyMethod</CODE> within the class <CODE>MyClass</CODE> in <CODE>MyFile.exe </CODE>and displays the output to the console window.</P>

<PRE>ildasm /item:MyClass::MyMethod MyFile.exe /text</PRE>

<P>In the previous example, there could be several <CODE>MyMethod</CODE> methods with different signatures. The following command disassembles the method <CODE>MyMethod</CODE> with the return type of <B>void</B> and the parameters
<i>int32</i> and <i>System.String</i>. </P>

<PRE>ildasm /item:"MyClass::MyMethod(void(int32,class System.String))" MyFile.exe /text</PRE>

<H4>See Also</H4>

<P><a href="Tools_Index.html">Tools Index</a> | <A HREF="ilasm.html">CIL Assembler (ilasm.exe)</A> </P>
<hr>
<p><i>Copyright (c) 2006 Microsoft Corporation. All rights reserved.</i></p>
</BODY>
</HTML>